package com.uvnos4j.matilda.commons.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * Tree节点的抽象父类
 *
 * @param <T> Tree节点的具体类型
 * @author Guo.wl
 */
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class AbstractTreeDomain<T extends BaseDomain> extends BaseDomain {

    /**
     * 父ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    protected transient Long parentId;

    /**
     * 子集合
     */
    protected transient List<T> children;

    /**
     * 判断是否是根节点对象
     *
     * @return 是否是根节点
     */
    public abstract boolean isRoot();

}